package itdep.common.domain;

import org.springframework.beans.support.SortDefinition;
import org.springframework.stereotype.Repository;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
@Repository
public interface GenericEntityDao<PK extends Serializable, E extends Entity<PK>> {

	E get(PK pk);

	int countAll();

	List<E> findAll(int start, int count, SortDefinition... sortDefinitions);

	List<PK> findAllKeys(int start, int count, SortDefinition... sortDefinitions);

	E create();

	void save(E entity);

	void saveAll(final Collection<? extends E> entities);

	void update(E entity);

	void updateAll(final Collection<? extends E> entities);

	void saveOrUpdate(E entity);

	void saveOrUpdateAll(final Collection<? extends E> entities);

	void merge(final E entity);

	void delete(E entity);

	void deleteAll(final Collection<? extends E> entities);

	int executeNamedQuery(final String query, final Map<String, Object> parameters);

}
